<?php

/**
 * This is the model class for table "_shop_product".
 *
 * The followings are the available columns in table '_shop_product':
 * @property string $id
 * @property string $name
 * @property string $alias
 * @property string $details1
 * @property string $details2
 * @property string $details3
 * @property string $details4
 * @property string $details5
 * @property string $creation_datetime
 * @property string $last_update
 * @property boolean $status
 * @property boolean $custom_url
 * @property boolean $page_details
 */
class ProductBase extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Product the static model class
	 */
	public static function model($className='Product')
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return SITE_ID.'_shop_product';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('details1', 'required'),
			array('name', 'length', 'max'=>1500),
			array('alias', 'length', 'max'=>200),
			array('details2, details3, details4, details5', 'length', 'max'=>5000),
			array('creation_datetime, last_update, status, custom_url, page_details', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, custom_url, page_details, alias, details1, details2, details3, details4, details5, creation_datetime, last_update, status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'alias' => 'Alias',
			'details1' => 'Details1',
			'details2' => 'Details2',
			'details3' => 'Details3',
			'details4' => 'Details4',
			'details5' => 'Details5',
			'creation_datetime' => 'Creation Datetime',
			'last_update' => 'Last Update',
			'status' => 'Status',
			'custom_url' => 'Custom URL',
			'page_details' => 'Page Details',
			'bv_review_id' => 'Bazaarvoice Review Id',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('alias',$this->alias,true);
		$criteria->compare('details1',$this->details1,true);
		$criteria->compare('details2',$this->details2,true);
		$criteria->compare('details3',$this->details3,true);
		$criteria->compare('details4',$this->details4,true);
		$criteria->compare('details5',$this->details5,true);
		$criteria->compare('creation_datetime',$this->creation_datetime,true);
		$criteria->compare('last_update',$this->last_update,true);
		$criteria->compare('status',$this->status);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}